package 笔试.腾讯;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author:谢君臣
 * @Date:2021/8/23-10:46
 * @version:1.0
 * @function:
 */
public class Main06 {
    public static void main(String[] args) {
        int count = 0, i = 0;
        int flag1 = 0, flag2 = 0, flag3 = 0, flag4 = 0;
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        List<String> arr = new ArrayList<>();
        for (; i < line.length() && arr.size() < 20; i++) { //判断非相邻重重的前20个
            if (i > 0 && String.valueOf(line.charAt(i)).equals(arr.get(arr.size() - 1))) { // 重复
                count++;
            } else {
                if (flag1 == 0 && line.charAt(i) >= 'a' && line.charAt(i) <= 'z') flag1 = 1;
                else if (flag2 == 0 && line.charAt(i) >= 'A' && line.charAt(i) <= 'Z') flag2 = 1;
                else if (flag3 == 0 && line.charAt(i) >= '0' && line.charAt(i) <= '9') flag3 = 1;
                else if (flag4 == 0 && (line.charAt(i) == ',' && line.charAt(i) == '.' && line.charAt(i) == '!' && line.charAt(i) == '?' && line.charAt(i) == ';'))
                    flag4 = 1;
                arr.add(String.valueOf(line.charAt(i)));
            }
        }
        int temp = 4 - flag1 - flag2 - flag3 - flag4;//四基础条件不成立个数
        if (arr.size() < 6) { // 需要填充字符
            if (count>=temp)
                System.out.println((arr.size() + count) >= 6 ? count : 6 - arr.size());
            else
                System.out.println((arr.size() + temp) >= 6 ? temp : 6 - arr.size());
        } else { // 不需要填充字符
            if (count >= temp) System.out.println(count + line.length() - i);
            else System.out.println(temp + line.length() - i);
        }
    }
}
